import 'package:get_storage/get_storage.dart';

class Logger{

  write(str){
    final box = GetStorage();
    String log = '';
    if(box.hasData('log')){
      log = box.read('log');
      if(log.length>1000000){
        log = '';
        delete();
      }
    }
    str = '${DateTime.now()}       $str';
    log = str+log;
    box.write('log', log);
  }
  read(){
    final box = GetStorage();
    String log = '';
    if(box.hasData('log')){
      log = box.read('log');
    }
    return log;
  }

  delete(){
    final box = GetStorage();
    box.remove('log');
  }
}